Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improvement cql stmt generation #435

Conversation

CodeLieutenant
Copy link
Contributor

  1. Refactoring the Statement Generators into generators package
  2. Each table gets it's own random number for validation and generation
  3. Warmup consolidated into Job, runs with its own validator and
    statement generator -> propably can be removed, as Warmup is just a
    mutation without DDL and deletes

Future Plans

  1. Remove stopFlag as context.Context can do the same, hard kill is
    to CANCEL the Global Parent, and soft kill is cancelation of the
    current context
  2. Generators Refactoring

@CodeLieutenant CodeLieutenant added the enhancement New feature or request label Oct 25, 2024
@CodeLieutenant CodeLieutenant self-assigned this Oct 25, 2024
@CodeLieutenant CodeLieutenant force-pushed the improvement-cql-stmt-generation branch 2 times, most recently from 776f81b to 905daff Compare October 25, 2024 10:48
Copy link

@DanielHe4rt DanielHe4rt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amazing Refactor, @CodeLieutenant! I just had a couple of questions related to the implementation itself.

Btw, since you're reorganizing the whole code would be a good thing to drop some DocBlocks around things you think that's important for people to understand before jump into the code.

Comment on lines +32 to +38
sleep := time.Duration(0)

func NewPump(stopFlag *stop.Flag, logger *zap.Logger) chan time.Duration {
pump := make(chan time.Duration, 10000)
logger = logger.Named("Pump")
go func() {
logger.Debug("pump channel opened")
defer func() {
close(pump)
logger.Debug("pump channel closed")
}()
for !stopFlag.IsHardOrSoft() {
pump <- newHeartBeat()
}
}()
if rand.Int()%chance == 0 {
sleep = sleepDuration
}

return pump
pump <- sleep

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why it should sleep? Can you explain me exactly how it acts?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Burst mechanism, makes a user of this, sleep after change is hit. practically if you make change = 10.

It will sleep approximatly one in 10. This is just to not overload the server

pkg/generators/generator.go Show resolved Hide resolved
Statement generation currently does not work as intended,
gemini generates values for primary and clustering keys,
that are completply invalid. The are not just off by value,
but also off by type, e.g. generates `text` for `timeuuid`.
This is the first step in resolving this issue, by refactoring
how, when and where statements are generated.

Signed-off-by: Dusan Malusev <[email protected]>
1. Refactoring the Statement Generators into generators package
2. Each table gets it's own random number for validation and generation
3. Warmup consolidated into Job, runs with its own validator and
   statement generator -> propably can be removed, as Warmup is just a
   mutation without DDL and deletes

Future Plans
1. Remove stopFlag as context.Context can do the same, hard kill is
   to CANCEL the Global Parent, and soft kill is cancelation of the
   current context
2. Generators Refactoring

Signed-off-by: Dusan Malusev <[email protected]>
context.Context

Go has built it mehanizm to stop the execution of the long running
process, like goroutines and network requests, and many libraries using
inside gemini support it, lets just make a heavy usage of it, cause we
can.

Signed-off-by: Dusan Malusev <[email protected]>
@CodeLieutenant CodeLieutenant force-pushed the improvement-cql-stmt-generation branch from bcf3e1f to 185729d Compare November 14, 2024 13:10
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why this is removed in this commmit context ?

pkg/jobs/jobs.go Outdated
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the main thing missing from this commit description is, what's wrong with the stopFlags

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Multiple issues, it's too complex, makes gemini stuck sometimes when SIGTERM or SIGINT is sent and it's never tested, context.Context is in stdlib, fully tested and everybody in go ecosystem knows how to use it. TLDR makes gemini code shorted and easier to maintain without hiccups

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • too complex is a bit vague argument.
  • "everybody in go ecosystem knows how to use" - maybe I'm not yet that familiar of go ecosystem evaluate that statement.

we need to write all of it down, i.e. what the shortcoming of it, vs. what is the advantages of context.Context
preferably in the commit message / PR description

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants